import csv
import unittest
from BeautifulReport import BeautifulReport


class TestCsvCases(unittest.TestCase):

    def test_csv_rows(self):
        suite = unittest.TestSuite()
        with open('../../params.csv', 'r', encoding='utf-8') as file:
            reader = csv.reader(file)
            for row_number, row in enumerate(reader, start=1):
                def test_case(self):
                    # 假设CSV每行有两个字段，可以根据需求修改
                    field1, field2 = row
                    # 这里可以添加具体的测试逻辑
                    self.assertTrue(field1 == "expected_value")  # 示例断言
                    # suite.addTest(TestCsvCases(test_name))
                test_name = f'test_row_{row_number}'
                setattr(self, test_name, test_case)
                print(suite)
            suite = unittest.defaultTestLoader.discover('..', pattern='test*.py')
            result = BeautifulReport(suite)
            result.report(filename='测试报告', description='这是一个测试报告', report_dir='./reports', theme='theme_default')


if __name__ == '__main__':
    unittest.main()